<?php
/**
 * The template for displaying Search Results pages
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

get_header(); get_template_part('block', 'search'); ?>
    <section id="primary" class="site-content fix">
        <div class="box-article">
            <div class="data">
                <?php
                while ( have_posts() ) : the_post();
                    $description = get_post_custom_values('description', get_the_ID());  if(is_array($description) && current($description) != false) $description = current($description); else $description = get_the_title();
                    if(get_post_type( get_the_ID() ) == 'post'):
                    ?>
                    <article class="item">
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                            <img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) );?>" width="300" height="180" alt="<?php the_title(); ?>"/>
                        </a>
                        <h3>
                            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
                        </h3>
                        <time datetime="2014-09-26"><?php echo the_date('H:i -  l, d/m/Y');?></time>
                        <p>
                            <?php echo the_titlesmall($description, 30, '...') ?>
                        </p>
                    </article>
                <?php endif; endwhile;?>

            </div>
        </div>
        <?php wp_pagenavi(); ?>
    </section><!-- #primary -->
<?php get_footer(); ?>